<?php
/**
 * Classe para abstração de URLs. Processa também URLs virtuais do FrameWork
 *
 */
class FkEditorHelper extends Helper
{
	private $_context;
	
	public function FkEditorHelper($context)
	{	
		include_once($context->PathWebRoot(). FileUtil::Slash() . "editor/fckeditor/fckeditor.php") ;	
		$this->_context = $context;		
	}
	
	public function textarea($fieldName, $valor = '', $attributes = '')
	{
		$fieldName = $this->processName($fieldName);		
		$value = $this->_context->data[$fieldName['model']][$fieldName['name']];
		
		if(is_string($attributes))
			$attributes = $this->processAttribute($attributes);
			
		$oFCKeditor = new FCKeditor($fieldName['fieldName']) ;
		$oFCKeditor->BasePath = $this->_context->webroot() . 'editor/fckeditor/';	
		
		if($value)
		{
			$oFCKeditor->Value = $value;
		}
		else
		{
			if($valor)
			{
				$oFCKeditor->Value =$valor;
			}
		}
		if(!empty($attributes['width']))
		{
			$oFCKeditor->Width = "'".$attributes['width']."'";
		}
		if(!empty($attributes['height']))
		{
			$oFCKeditor->Height = "'".$attributes['height']."'";
		}
		$oFCKeditor->Create() ;
	}
}
?>